<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE>
<html>
<head>
<base href="<%=basePath%>">
<jsp:include page="/static/iframe/import/_meta.jsp"></jsp:include>
<jsp:include page="/static/iframe/import/_header.jsp"></jsp:include>
<jsp:include page="/static/iframe/import/_footer.jsp"></jsp:include>
<link rel="stylesheet"
	href="static/iframe/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet"
	href="static/iframe/bootstrap/css/bootstrapValidator.min.css">
<link rel="stylesheet"
	href="static/iframe/bootstrap/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css">
<title>添加区域</title>

<style>
.row {
	margin-right: 5px;
	margin-left: 5px;
	margin-top: 5px;
}

}
.form-bottom {
	margin-bottom: 20px;
}
</style>
</head>
<body>
	<div class="page-container">
		<div class="container-fluid">
			<form class="form-horizontal" method="post" id="myform">
				<div class="row">
					<div class="col-sm-4 col-md-4 col-lg-3">
						<div class="form-group">
							<div class="input-group">
								<span class="input-group-addon"> <span
									class="c-red text-danger">*&nbsp;</span>&nbsp;省&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;份
								</span> <input type="text" class="form-control" placeholder="省份"
									name="province" />
							</div>
						</div>
					</div>

					<div class="col-sm-4 col-md-4 col-lg-3">
						<div class="form-group">
							<div class="input-group">
								<span class="input-group-addon"><span
									class="c-red text-danger">*&nbsp;</span>&nbsp;城&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;市:</span>
								<input type="text" class="form-control" name="city"
									placeholder="城市" />
							</div>
						</div>
					</div>

					<div class="col-sm-4 col-md-4 col-lg-3">
						<div class="form-group">
							<div class="input-group">
								<span class="input-group-addon"><span
									class="c-red text-danger">*&nbsp;</span>&nbsp;区&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;域:</span>
								<input type="text" class="form-control" name="district"
									placeholder="区域" />
							</div>
						</div>
					</div>

					<div class="col-sm-4 col-md-4 col-lg-3 ">
						<div class="form-group">
							<div class="input-group">
								<span class="input-group-addon"><span
									class="c-red text-danger">*&nbsp;</span>&nbsp;邮政编码:</span> <input
									type="text" class="form-control" name="postCode"
									placeholder="邮政编码" />
							</div>
						</div>
					</div>
					<!-- 
					<div class="col-sm-4 col-md-4 col-lg-3 ">
						<div class="form-group">
							<div class="input-group">
								<span class="input-group-addon"><span class="c-red">*&nbsp;</span>&nbsp;简&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:</span>
								<input type="text" class="form-control" name="shortCode"
									placeholder="简码" />
							</div>
						</div>
					</div>
					<div class="col-sm-4 col-md-4 col-lg-3 ">
						<div class="form-group">
							<div class="input-group">
								<span class="input-group-addon"><span class="c-red">*&nbsp;</span>&nbsp;城市编码:</span>
								<input type="text" class="form-control" name="cityCode"
									placeholder="城市编码" />
							</div>
						</div>
					</div>
				</div>
 -->
					<div class="col-sm-12 col-md-12 col-lg-12 text-center">
						<div class="tooltip-demo">
							<div class="form-bottom">
								<button type="submit" class="btn btn-primary">
									<i class="glyphicon glyphicon-ok"></i>&nbsp;提交
								</button>
								&nbsp;
								<button class="btn btn-success" type="reset" id="reset">
									<i class="glyphicon glyphicon-refresh"></i>&nbsp;重置
								</button>
								&nbsp; <a class="btn btn-white" href="javascript:layer_close()"
									target="_blank"><i class="glyphicon glyphicon-share-alt"></i>&nbsp;返回</a>
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
</body>
<script type="text/javascript"
	src="static/iframe/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript"
	src="static/iframe/bootstrap/js/bootstrapValidator.min.js"></script>
<script type="text/javascript"
	src="static/iframe/bootstrap/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript"
	src="static/iframe/bootstrap/bootstrap-datetimepicker/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript" src="static/plugins/window/layershow.js"></script>
<script type="text/javascript">
	$(function() {
		$("#myform").bootstrapValidator({
			feedbackIcons : {
				valid : 'glyphicon glyphicon-ok',
				invalid : 'glyphicon glyphicon-remove',
				validating : 'glyphicon glyphicon-refresh'
			},
			fields : {
				province : {
					message : '省份验证失败',
					validators : {
						/* remote : {
							url : "",//user/addUserCheckUserName
							message : "该用户已经使用!",
							delay : 500,
							type : 'post'
						}, */
						notEmpty : {
							message : '省份不能为空'
						}
					}
				},
				city : {
					message : '城市验证失败',
					validators : {
						notEmpty : {
							message : '城市不能为空'
						}
					}
				},
				district : {
					message : '区域验证失败',
					validators : {
						/* remote : {
						url : "",//user/addUserCheckUserName
						message : "该用户已经使用!",
						delay : 500,
						type : 'post'
						}, */
						notEmpty : {
							message : '区域不能为空'
						}
					}
				},
				postCode : {
					message : '邮政编码验证失败',
					validators : {
						notEmpty : {
							message : '邮政编码不能为空'
						},
						regexp : {
							regexp : /^[1-9]\d{5}$/,
							message : '中国邮政编码为6位数字'
						}
					}
				}
			}
		//做ajax请求用到
		}).on('success.form.bv', function(e) {
			e.preventDefault();
			var $form = $(e.target); //拿到form表单
			layer.load(2, {
				time : 1000
			});
			setTimeout(function() {
				//请求注册用户
				$.ajax({
					type : "post",
					url : "region/addRegion",
					dataType : "json",
					data : $form.serialize(),
					success : function(result) {
						if (result.flag) {
							layer.msg(result.msg, {
								time : 1500,
								icon : 1
							});
							setTimeout(function() {
								window.parent.location.reload();
							}, 1500);
						} else {
							layer.msg(result.msg, {
								time : 1500,
								icon : 2
							});
						}
					}
				});
			}, 1000);
		});

		$("#reset").click(function() {
			$("#myform").data('bootstrapValidator').resetForm();
		});
	});
</script>

<!--[if lt IE 10]>
    <script type="text/javascript" src="static/plugins/js/input-placeholder/ieplaceholder.js"></script>
    <![endif]-->
</html>